import { mineApi } from "@/utils/request/api/mine";
const { imgUrl } = getApp().globalData;
Page({
  data: {
    type: "add",
    imgUrl: imgUrl + "mine/",
    list: [],
  },
  jumpToAdd() {
    wx.navigateTo({
      url: "/pages/mine/enterpriseMonitor/addMonitor/addMonitor"
    });
  },
  jumpToDetail(event) {
    const { index } = event.currentTarget.dataset;
    let obj = JSON.parse(JSON.stringify(this.data.list[index]));
    wx.navigateTo({
      url: "/pages/mine/enterpriseMonitor/addMonitor/addMonitor",
      success: function (res) {
        res.eventChannel.emit("edit", { data: obj });
      },
    });
  },
  onLoad(options) {

  },
  onReady() {},
  onShow() {
    mineApi.getMonitorList().then((res) => {
      console.log("res === ", res);
      this.setData({
        list: res.data.map((item) => {
          item.created_at = item.created_at.split(" ")[0];
          return item;
        }),
      });
    });
  },
  onHide() {},
  onUnload() {},
  onShareAppMessage() {
    return {
      title: "",
    };
  },
});
